<?
	include("common.php");

	if(!$loggedin){
		ob_start();
		header("Location: login.php");
	}
	if( $_POST['step2'] ){
		if( $_POST['oldpassword'] && $_POST['password'] && $_POST['password2'] ){
			$query = "SELECT * FROM users WHERE uid='$myuid'";
			$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
			if ( ($result) && (mysql_num_rows($result) > 0) ){
				$row = mysql_fetch_object($result);
				if( $row->password != $_POST['oldpassword'] ){
					errform('The current password you entered does not match what is on file.', 'oldpassword'); // #err
				}
				$newpass = $_POST['password'];
				$newpass2 = $_POST['password2'];
				if( $newpass != $newpass2 ){
					errform('the new password must match what you re-type'); // #err
				}
				if( !$posterr ){
					$qr1 = mysql_query("UPDATE users SET password='$password' WHERE uid='$myuid'") or die( mysql_error() );
				}
			}
		}
		$query = "SELECT * FROM users WHERE uid='$myuid'";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		if ( ($result) && (mysql_num_rows($result) > 0) ){
			if( !$posterr ){
				$qr1 = mysql_query("UPDATE users SET 
					name='".$_POST['name']."',
					email='".$_POST['email']."',
					b_month='".$_POST['bmonth']."',
					b_year='".$_POST['byear']."',
					b_day='".$_POST['bday']."',
					address='".$_POST['address']."',
					homepage='".$_POST['homepage']."',
					icq='".$_POST['icq']."',
					aol='".$_POST['aol']."',
					yahoo='".$_POST['yahoo']."',
					msn='".$_POST['msn']."',
					interest='".$_POST['interest']."',
					ocupation='".$_POST['ocupation']."',
					links='".$_POST['links']."' WHERE uid='$myuid'") or die( mysql_error() );
				ob_start();
				header("Location: account.php");
			}
		}
	}
	include("header.php");
		$query = "SELECT * FROM users WHERE uid='$myuid'";
		$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
		$row = mysql_fetch_object( $result );
?>
		<FONT face=arial size=3><b>Edit Profile:</b><br>
		<form method=post>
		<TABLE cellSpacing=0 cellPadding=0 width=90% border=0>
		<TR>
			<TD width=100%>
				<TABLE cellPadding=3 width=100% border=0>
				<TR>
					<TD width=40%><FONT face=arial size=3><B>Current Password:</B></FONT></TD>
					<TD><input type=password name=oldpassword size=30></font>
				<TR>
					<TD width=40%><FONT face=arial size=3><B><b>New Password (required)</b>
					<TD><input type=password name=password size=30 maxlength="12"><i> [5-12 characters]</i></font>
				<TR>
					<TD width=40%><FONT face=arial size=3><B><b>Verify Password (required)</b>
					<TD><input type=password name=password2 size=30 maxlength="12"><i>[re-enter password]</i></font>
				</TR>
				<tr>
					<td><font face="arial" size="2"><b>Your Name (required)</b></td>
					<td><font face="arial" size="2"><input type=text name=name size=30 maxlength="30" value="<?=$row->name?>"><i> [2-12 characters]</i></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Username (required)</b></td>
					<td><font face="arial" size="2"><input type=text name=username size=30 maxlength="30" value="<?=$row->username?>"><i> [2-12 characters]</i></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Email Address (required)</b></td>
					<td><font face="arial" size="2"><input type=input name=email size=30 maxlength="40" value="<?=$row->email?>"><i> [valid email address]</i></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Location</b></td>
					<td><font face="arial" size="2"><input type=input name=address size=30 maxlength="40" value="<?=$row->address?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Web Site</b></td>
					<td><font face="arial" size="2"><input type=input name=homepage size=30 maxlength="40" value="<?=$row->homepage?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>ICQ Number</b></td>
					<td><font face="arial" size="2"><input type=input name=icq size=30 maxlength="40" value="<?=$row->icq?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>AOL Messenger</b></td>
					<td><font face="arial" size="2"><input type=input name=aol size=30 maxlength="40" value="<?=$row->aol?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Yahoo Messenger</b></td>
					<td><font face="arial" size="2"><input type=input name=yahoo size=30 maxlength="40" value="<?=$row->yahoo?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>MSN Messenger</b></td>
					<td><font face="arial" size="2"><input type=input name=msn size=30 maxlength="40" value="<?=$row->msn?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Interests</b></td>
					<td><font face="arial" size="2"><input type=input name=interest size=30 maxlength="40" value="<?=$row->interest?>"><i> [optional]</i><br></td>
				</tr>
				<tr>
					<td><font face="arial" size="2"><b>Ocupation</b></td>
					<td><font face="arial" size="2"><input type=input name=ocupation size=30 maxlength="40" value="<?=$row->ocupation?>"><i> [optional]</i><br></td>
				</tr>
				<TR>
					<TD colspan=2>
					<input type="hidden" name="action" value="change"><br>
					<font face="arial" size="2"><input type="submit" name="step2" value="Edit Profile" tabindex="6" style="background-color:#e5e5e5; color:#000000; font-family:Verdana,Arial; font-weight: bold; font-size: 11px; border-left: 1 solid #a0a0a0; border-top: 1 solid #a0a0a0; border-right: 1 solid #000000; border-bottom: 1 solid #000000; padding: 2 2 2 2; outline: #a0a0a0 solid 2px;">
					</TD>
				</TR>
				</TABLE>
			</TD>
		</TR>
		</TABLE><BR>
		</form>
<?
	include("footer.php");
?>